"""
购买iphone练习
"""

class Iphone():

    def __init__(self,store,color):
        self.storage = store
        self.color = color

    def buy(self):
        print(f'您购买的手机存储为{self.storage}G,颜色为{self.color},价格为{self.price()}')

    def price(self):
        if self.storage ==64:
            return 4999
        elif self.storage == 128:
            return 5499
        elif self.storage == 256:
            return 6999
        else:
            return '不存在此版本'


#静态方法  用于类来调用
    @staticmethod
    def for_sale(total_price):
        if total_price >= 10000:
            return total_price - 500

if __name__ == '__main__':

    iphone1 = Iphone(256,'red')
    iphone1.buy()

    iphone2 = Iphone(64,'black')
    iphone2.buy()
    total_price = iphone1.price()+iphone2.price()
    print(iphone1.price()+iphone2.price())
    print(Iphone.for_sale(11998))

